﻿Public Class PopupNotifierCollection
    Inherits CollectionBase

    Sub New()

    End Sub

    Protected Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
        MyBase.OnSet(index, oldValue, newValue)
    End Sub

    Protected Overrides Sub OnInsert(ByVal index As Integer, ByVal value As Object)
        MyBase.OnInsert(index, value)
    End Sub

    Default ReadOnly Property Item(ByVal Index As Integer) As PopupNotifier
        Get
            Return DirectCast(List(Index), PopupNotifier)
        End Get
    End Property

    Public Function Add(ByVal value As PopupNotifier) As PopupNotifier
        List.Add(value)
        Return value
    End Function

    Public Function Contains(ByVal value As PopupNotifier) As Boolean
        Return List.Contains(value)
    End Function

    Public Sub Remove(ByVal value As PopupNotifier)
        List.Remove(value)
    End Sub

    Public Function IndexOf(ByVal value As PopupNotifier) As Integer
        Return List.IndexOf(value)
    End Function

    Public Shadows Sub Clear()
        MyBase.Clear()
    End Sub

    Sub Popup()
        For Each Item As PopupNotifier In List
            Item.Popup(List.IndexOf(Item))
        Next
        Clear()
    End Sub

End Class
